// index.js
Page({
  data: {
    showResult: false,
    manualInput: '',
    wordList: [
      { text: 'Hello', phonetic: '/həˈləʊ/', selected: false },
      { text: 'World', phonetic: '/wɜːld/', selected: false },
      { text: 'Example', phonetic: '/ɪɡˈzɑːmpl/', selected: false }
    ],
    selectedIcon: '',
    unselectedIcon: ''
  },
  
  // 返回上一页
  goBack: function() {
    wx.navigateBack();
  },
  
  // 拍照
  takePhoto: function() {
    this.setData({
      showResult: true
    });
  },
  
  // 切换选择状态
  toggleSelect: function(e) {
    const index = e.currentTarget.dataset.index;
    const key = `wordList[${index}].selected`;
    this.setData({
      [key]: !this.data.wordList[index].selected
    });
  },
  
  // 手动输入处理
  onManualInput: function(e) {
    this.setData({
      manualInput: e.detail.value
    });
  },
  
  // 添加到记忆本
  addToMemory: function() {
    wx.showToast({
      title: '添加成功',
      icon: 'success'
    });
  }
});